<?php
namespace Home\Model;
use Think\Model\MongoModel;
Class BookTypeModel extends MongoModel {
	Protected $pk = 'id';
	Protected $_idType = self::TYPE_INT;
   	protected $_autoinc =  true;
   	protected $tableName = 'book_type';
	
	
	public function get_list()
	{
		return M('book_type')->order('order')->select();
	}
	
	public function add($data)
	{
		return M('book_type')->add($data);
	}
	
	public function edit($id,$data)
	{
		$MongoId = new \MongoId($id);
		return M('book_type')->where(array('_id'=>$MongoId))->save($data);
	}
	
	public function find($id)
	{
		$MongoId = new \MongoId($id);
		$res = M('book_type')->where(array('_id'=>$MongoId))->select();
		//echo  M('book')->getLastSql(); 
		return $res;
	}
	
	public function del($id)
	{
		$MongoId = new \MongoId($id);
		return M('book_type')->where(array('_id'=>$MongoId))->delete();
	}
	
}